package com.topera.eduservice.controller;

import com.topera.commonutils.R;
import com.topera.eduservice.entity.subject.SubjectNode;
import com.topera.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author puzhenjiang
 * @since 2020-05-17
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;

    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){

        eduSubjectService.addSubject(file,eduSubjectService);
        return R.ok();
    }

    /**
     * 获取课程分类  树表展示
     * @return
     */
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<SubjectNode> subjectList = eduSubjectService.getAllSubject();
        return R.ok().data("subjectList",subjectList);
    }
}

